#pragma once


#include <set>
#include "Thread.h"
#include "Condition.h"

namespace yazi{
namespace thread{

class ThreadPool{
public:
    ThreadPool();
    virtual ~ThreadPool();

    void create(int size);

    Thread* get_idle_thread();
    int get_idle_thread_num();
    int get_busy_thread_num();
    void move_to_idle(Thread*);
    void move_to_busy(Thread*);

    void assign(Task* task);
private:
    std::set<Thread*> m_list_idle;
    std::set<Thread*> m_list_busy;
    Mutex m_mutex_idle;
    Mutex m_mutex_busy;
    Condition m_cond_idle;
    Condition m_cond_busy;
};


}}